<?php
include_once("sessionmanager.php");
initSession();

if (!isset($_SESSION['s_loggedin']) || ($_SESSION['s_loggedin'] == false) || !isset($_SESSION['s_serverurl']) || (strpos($_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'],$_SESSION['s_serverurl']) === false)) {
	$error_page_code = "timeout";
	include "errorpage.php";
	exit();
}
if (!$_SESSION['s_cansearch']) {
	$error_page_code = "permission";
	include "errorpage.php";
	exit();
}
include "languages.php";
include_once "functions.inc.php";
include "attributes.php";
$userid = $_SESSION['s_userid'];

makeheader(SHOW_TITLE);

if (isset($_POST['entries'])) {
	unset($_SESSION['s_hits']);
	$_SESSION['s_hits'] = (int)$_POST['entries'];
}
$entries_per_page = $_SESSION['s_hits'];

if ((!isset($_GET['page']) && !isset($_POST['searchbutton']) && !isset($_GET['ally']) && !isset($_GET['spieler'])) || isset($_GET['new'])) {
	// Sessionvars killen
	unset($_SESSION['s_allysuche']);
	unset($_SESSION['s_spielersuche']);
	unset($_SESSION['s_moonsearch']);
	unset($_SESSION['s_colonysearch']);
	unset($_SESSION['s_sorder1']);
	unset($_SESSION['s_sorder2']);
	unset($_SESSION['s_checked1']);
	unset($_SESSION['s_checked2']);
	unset($_SESSION['s_noticesearch']);
	unset($_SESSION['s_reportsearch']);
	unset($_SESSION['s_nchecked1']);
	unset($_SESSION['s_nchecked2']);
	unset($_SESSION['s_rchecked1']);
	unset($_SESSION['s_rchecked2']);
	unset($_SESSION['s_cchecked1']);
	unset($_SESSION['s_cchecked2']);
	unset($_SESSION['s_schecked1']);
	unset($_SESSION['s_schecked2']);
	unset($_SESSION['s_schecked3']);
	unset($_SESSION['s_schecked4']);
	unset($_SESSION['s_galaxie']);
	unset($_SESSION['s_system1']);
	unset($_SESSION['s_system2']);
	unset($_SESSION['s_planet1']);
	unset($_SESSION['s_planet2']);
	unset($_SESSION['s_status1']);
	unset($_SESSION['s_status2']);
	unset($_SESSION['s_status3']);
	unset($_SESSION['s_sort']);
	unset($_SESSION['s_datevalue']);
	unset($_SESSION['s_tyear']);
	unset($_SESSION['s_tmonth']);
	unset($_SESSION['s_tday']);
	unset($_SESSION['s_thour']);
	unset($_SESSION['s_minute']);
	unset($_SESSION['s_second']);
	unset($_SESSION['s_metal']);
	unset($_SESSION['s_crystal']);
	unset($_SESSION['s_both']);
	unset($_SESSION['s_minrank']);
	unset($_SESSION['s_minfrank']);
	unset($_SESSION['s_maxrank']);
	unset($_SESSION['s_maxfrank']);
	unset($_SESSION['s_bbcodes']);
}

require "config.php";
mysql_connect($dbhost,$dbusername,$dbpassword) or die(PARSER_ERROR3);
mysql_select_db($dbname) or die(PARSER_ERROR2);

$allysuche = "";
$spielersuche = "";
$galaxie = "";
$system1 = "";
$system2 = "";
$planet1 = "";
$planet2 = "";
$moonsearch = 0;
$noticesearch = 0;
$reportsearch = 0;
$colonysearch = 0;
$minrank = 0;
$minfrank = 0;
$maxrank = 1500;
$maxfrank = 1500;
$sortarray = array("Galaxie/System","Spielername","Allianzname");
if (isset($_GET['page']) && is_numeric($_GET['page'])) $page = (int)$_GET['page'];
else $page = 1;
$limit = " LIMIT ".(($page-1)*$entries_per_page).",".$entries_per_page;

if (isset($_POST['ally']) && !empty($_POST['ally'])) {
	$allysuche = trim(addslashes(strip_tags($_POST['ally'])));
	$allysuche = preg_replace("/[^a-zA-Z0-9\*\s-_.]/","", $allysuche);
}
if (isset($_GET['ally']) && !empty($_GET['ally'])) {
	$allysuche = trim(addslashes(strip_tags($_GET['ally'])));
	$allysuche = preg_replace("/[^a-zA-Z0-9\*\s-_.]/","", $allysuche);
}

if (isset($_POST['spieler']) && !empty($_POST['spieler'])) {
	$spielersuche = trim(strip_tags($_POST['spieler']));
	$spielersuche = preg_replace("/[\'\"?%\\\\]/","", $spielersuche);
}
if (isset($_GET['spieler']) && !empty($_GET['spieler'])) {
	$spielersuche = trim(strip_tags($_GET['spieler']));
	$spielersuche = preg_replace("/[\'\"?%\\\\]/","", $spielersuche);
}
if (isset($_POST['moonsearch']) && !empty($_POST['moonsearch'])) {
	$moonsearch = trim(addslashes(strip_tags($_POST['moonsearch'])));
}
if (isset($_POST['noticesearch']) && !empty($_POST['noticesearch'])) {
	$noticesearch = trim(addslashes(strip_tags($_POST['noticesearch'])));
}
if (isset($_POST['colonysearch']) && !empty($_POST['colonysearch'])) {
	$colonysearch = trim(addslashes(strip_tags($_POST['colonysearch'])));
}
if (isset($_POST['reportsearch']) && !empty($_POST['reportsearch'])) {
	$reportsearch = trim(addslashes(strip_tags($_POST['reportsearch'])));
}
if (isset($_POST['galaxie']) && !empty($_POST['galaxie'])) {
	$galaxie = $_POST['galaxie'];
	$galaxie  = preg_replace("/([^0-9])/","",$galaxie);
}
if (isset($_POST['system1']) && !empty($_POST['system1'])) {
	$system1 = $_POST['system1'];
	$system1  = preg_replace("/([^0-9])/","",$system1);
	if ($system1 > 498) $system1 = 498;
	if ($system1 < 1) $system1 = 1;
}
if (isset($_POST['system2']) && !empty($_POST['system2'])) {
	$system2 = $_POST['system2'];
	$system2  = preg_replace("/([^0-9])/","",$system2);
	if ($system2 > 499) $system2 = 499;
	if ($system2 < 2) $system2 = 2;
}
if (isset($_POST['planet1']) && !empty($_POST['planet1'])) {
	$planet1 = $_POST['planet1'];
	$planet1  = preg_replace("/([^0-9])/","",$planet1);
	if ($planet1 > 14) $planet1 = 14;
	if ($planet1 < 1) $planet1 = 1;
}
if (isset($_POST['planet2']) && !empty($_POST['planet2'])) {
	$planet2 = $_POST['planet2'];
	$planet2  = preg_replace("/([^0-9])/","",$planet2);
	if ($planet2 > 15) $planet2 = 15;
	if ($planet2 < 2) $planet2 = 2;
}

if (isset($_POST['datevalue']) && is_numeric($_POST['datevalue'])) {
	$date_value = (int)$_POST['datevalue'];
} else $date_value = 0;
if (isset($_POST['year']) && is_numeric($_POST['year'])) {
	$tyear = (int)$_POST['year'];
} else $tyear = date("Y")-1;
if (isset($_POST['month']) && is_numeric($_POST['month'])) {
	$tmonth = (int)$_POST['month'];
} else $tmonth = date("m");
if (isset($_POST['day']) && is_numeric($_POST['day'])) {
	$tday = (int)$_POST['day'];
} else $tday = date("d");
if (isset($_POST['hour']) && is_numeric($_POST['hour'])) {
	$thour = (int)$_POST['hour'];
} else $thour = date("H");
if (isset($_POST['minute']) && is_numeric($_POST['minute'])) {
	$tminute = (int)$_POST['minute'];
} else $tminute = date("i");
if (isset($_POST['second']) && is_numeric($_POST['second'])) {
	$tsecond = (int)$_POST['second'];
} else $tsecond = date("s");
if (isset($_POST['metal']) && is_numeric($_POST['metal'])) {
	$metal = (int)$_POST['metal'];
} else $metal = 0;
if (isset($_POST['crystal']) && is_numeric($_POST['crystal'])) {
	$crystal = (int)$_POST['crystal'];
} else $crystal = 0;
if (isset($_POST['both']) && is_numeric($_POST['both'])) {
	$both = (int)$_POST['both'];
} else $both = 0;
if (isset($_POST['minrank']) && is_numeric($_POST['minrank'])) {
	$minrank = (int)$_POST['minrank'];
} else $minrank = 0;
if (isset($_POST['minfrank']) && is_numeric($_POST['minfrank'])) {
	$minfrank = (int)$_POST['minfrank'];
} else $minfrank = 0;
if (isset($_POST['maxrank']) && is_numeric($_POST['maxrank'])) {
	$maxrank = (int)$_POST['maxrank'];
} else $maxrank = 0;
if (isset($_POST['maxfrank']) && is_numeric($_POST['maxfrank'])) {
	$maxfrank = (int)$_POST['maxfrank'];
} else $maxfrank = 0;

if (isset($_POST['status1'])) $status1 = "checked"; elseif (!isset($_POST['done'])) $status1 = "checked"; else $status1 = "";
if (isset($_POST['status2'])) $status2 = "checked"; else $status2 = "";
if (isset($_POST['status3'])) $status3 = "checked"; else $status3 = "";
if (is_numeric($system1) && (!is_numeric($system2))) $system2= 499;
if (!is_numeric($system1) && (is_numeric($system2))) $system1= 1;
if (is_numeric($planet1) && (!is_numeric($planet2))) $planet2 = 15;
if (!is_numeric($planet1) && (is_numeric($planet2))) $planet1= 1;
if (($moonsearch==1 || $noticesearch == 1 || $reportsearch == 1) && (!is_numeric($system1))) $system1=1;
if (($moonsearch==1 || $noticesearch == 1 || $reportsearch == 1) && (!is_numeric($system2))) $system2=499;
if ($colonysearch == 1 && !is_numeric($planet1)) $planet1 = 1;
if ($colonysearch == 1 && !is_numeric($planet2)) $planet2 = 15;
if (isset($_POST['sort'])) $sort = $_POST['sort'];
else $sort = 0;
if (isset($_POST['sortorder'])) $sortorder = $_POST['sortorder'];
else $sortorder = 0;


// Spielersortierung
if ($sort == 0) {
	$sort = " ORDER BY galaxie,system,planet";
	$schecked1 = "checked";
	$schecked2 = "";
	$schecked3 = "";
	$schecked4 = "";
}
if ($sort == 1) {
	$sort = " ORDER BY spielername";
	$schecked1 = "";
	$schecked2 = "checked";
	$schecked3 = "";
	$schecked4 = "";
}
if ($sort == 2) {
	$sort = " ORDER BY ally";
	$schecked1 = "";
	$schecked2 = "";
	$schecked3 = "checked";
	$schecked4 = "";
}
if ($sort == 3) {
	$sort = " ORDER BY status";
	$schecked1 = "";
	$schecked2 = "";
	$schecked3 = "";
	$schecked4 = "checked";
}

$sorder1 = "";
$sorder2 = "";
if ($sortorder == 0) {
	$sort .= " ASC";
	$sorder1 = "checked";
} else {
	$sort .= " DESC";
	$sorder2 = "checked";
}

$date_checked0 = "";
$date_checked1 = "";
$date_checked2 = "";
if ($date_value == 0) {
	$date_checked0 = "checked";
} elseif ($date_value == 1) {
	$date_checked1 = "checked";
} elseif ($date_value == 2) {
	$date_checked2 = "checked";
}


$allysuche = (!isset($_POST['ally']) && !isset($_GET['ally']) && isset($_SESSION['s_allysuche'])) ? $_SESSION['s_allysuche'] : $allysuche;
$spielersuche = (!isset($_POST['spieler']) && !isset($_GET['spieler']) && isset($_SESSION['s_spielersuche'])) ? $_SESSION['s_spielersuche'] : $spielersuche;
$moonsearch = (!isset($_POST['moonsearch']) && isset($_SESSION['s_moonsearch'])) ? $_SESSION['s_moonsearch'] : $moonsearch;
$noticesearch = (!isset($_POST['noticesearch']) && isset($_SESSION['s_noticesearch'])) ? $_SESSION['s_noticesearch'] : $noticesearch;
$colonysearch = (!isset($_POST['s_colonysearch']) && isset($_SESSION['s_colonysearch'])) ? $_SESSION['s_colonysearch'] : $colonysearch;
$reportsearch = (!isset($_POST['reportsearch']) && isset($_SESSION['s_reportsearch'])) ? $_SESSION['s_reportsearch'] : $reportsearch;
$schecked1 = (!isset($_POST['sort']) && isset($_SESSION['s_schecked1'])) ? $_SESSION['s_schecked1'] : $schecked1;
$schecked2 = (!isset($_POST['sort']) && isset($_SESSION['s_schecked2'])) ? $_SESSION['s_schecked2'] : $schecked2;
$schecked3 = (!isset($_POST['sort']) && isset($_SESSION['s_schecked3'])) ? $_SESSION['s_schecked3'] : $schecked3;
$schecked4 = (!isset($_POST['sort']) && isset($_SESSION['s_schecked4'])) ? $_SESSION['s_schecked4'] : $schecked4;
$galaxie = (!isset($_POST['galaxie']) && isset($_SESSION['s_galaxie'])) ? $_SESSION['s_galaxie'] : $galaxie;
$system1 = (!isset($_POST['system1']) && isset($_SESSION['s_system1'])) ? $_SESSION['s_system1'] : $system1;
$system2 = (!isset($_POST['system2']) && isset($_SESSION['s_system2'])) ? $_SESSION['s_system2'] : $system2;
$planet1 = (!isset($_POST['planet1']) && isset($_SESSION['s_planet1'])) ? $_SESSION['s_planet1'] : $planet1;
$planet2 = (!isset($_POST['planet2']) && isset($_SESSION['s_planet2'])) ? $_SESSION['s_planet2'] : $planet2;
$status1 = (!isset($_POST['sort']) && isset($_SESSION['s_status1'])) ? $_SESSION['s_status1'] : $status1;
$status2 = (!isset($_POST['sort']) && isset($_SESSION['s_status2'])) ? $_SESSION['s_status2'] : $status2;
$status3 = (!isset($_POST['sort']) && isset($_SESSION['s_status3'])) ? $_SESSION['s_status3'] : $status3;
$sort    = (!isset($_POST['sort']) && isset($_SESSION['s_sort'])) ? $_SESSION['s_sort'] : $sort;
$date_value = (!isset($_POST['datevalue']) && isset($_SESSION['s_datevalue'])) ? $_SESSION['s_datevalue'] : $date_value;
$tyear   = (!isset($_POST['year']) && isset($_SESSION['s_tyear'])) ? $_SESSION['s_tyear'] : $tyear;
$tmonth  = (!isset($_POST['month']) && isset($_SESSION['s_tmonth'])) ? $_SESSION['s_tmonth'] : $tmonth;
$tday    = (!isset($_POST['day']) && isset($_SESSION['s_tday'])) ? $_SESSION['s_tday'] : $tday;
$thour   = (!isset($_POST['hour']) && isset($_SESSION['s_thour'])) ? $_SESSION['s_thour'] : $thour;
$tminute = (!isset($_POST['minute']) && isset($_SESSION['s_tminute'])) ? $_SESSION['s_tminute'] : $tminute;
$tsecond = (!isset($_POST['second']) && isset($_SESSION['s_tsecond'])) ? $_SESSION['s_tsecond'] : $tsecond;
$metal   = (!isset($_POST['metal']) && isset($_SESSION['s_metal'])) ? $_SESSION['s_metal'] : $metal;
$crystal = (!isset($_POST['crystall']) && isset($_SESSION['s_crystall'])) ? $_SESSION['s_crystall'] : $crystal;
$both    = (!isset($_POST['both']) && isset($_SESSION['s_both'])) ? $_SESSION['s_both'] : $both;
$minrank    = (!isset($_POST['minrank']) && isset($_SESSION['s_minrank'])) ? $_SESSION['s_minrank'] : $minrank;
$minfrank   = (!isset($_POST['minfrank']) && isset($_SESSION['s_minfrank'])) ? $_SESSION['s_minfrank'] : $minfrank;
$maxrank    = (!isset($_POST['maxrank']) && isset($_SESSION['s_maxrank'])) ? $_SESSION['s_maxrank'] : $maxrank;
$maxfrank   = (!isset($_POST['maxfrank']) && isset($_SESSION['s_maxfrank'])) ? $_SESSION['s_maxfrank'] : $maxfrank;

$date = $tyear."-".$tmonth."-".$tday." ".
$thour.":".$tminute.":".$tsecond." GMT";
$time = strtotime($date);
// Gerinfg�gige Ungenauigkeit durch Sommmer/Winterzeit gegeben (+-1 Stunde)

?>
<form name="suche" method="post" action="show.php">
<table cellpadding="1" cellspacing="0" border="0" align="center" width="95%"><tr><td>
<table class="standard" cellpadding="4" cellspacing="0" border="0" width="100%">
<tr class="tblhead"><td colspan="2"><?php echo SHOW_SEARCH; ?></td></tr>
<tr class="firstcolor"><td><?php echo SHOW_ALLYSYMBOL; ?></td>

<td><input class="textfield" name="ally" type="" value="<?php echo $allysuche; ?>" /></td>
</tr>
<tr class="firstcolor"><td><?php echo SHOW_PLAYERNAME; ?></td>
<td><input class="textfield" name="spieler" type="" value="<?php echo $spielersuche; ?>" /></td>
</tr>
<tr class="firstcolor"><td><?php echo SHOW_MOONS; ?></td>
<?php
if ($moonsearch==1) {
	$checked1="checked";
	$checked2="";
} else {
	$checked1="";
	$checked2="checked";
}
$checked1 = (!isset($_POST['moonsearch']) && isset($_SESSION['s_checked1'])) ? $_SESSION['s_checked1'] : $checked1;
$checked2 = (!isset($_POST['moonsearch']) && isset($_SESSION['s_checked2'])) ? $_SESSION['s_checked2'] : $checked2;
$sorder1 = (!isset($_POST['sortorder']) && isset($_SESSION['s_sorder1'])) ? $_SESSION['s_sorder1'] : $sorder1;
$sorder2 = (!isset($_POST['sortorder']) && isset($_SESSION['s_sorder2'])) ? $_SESSION['s_sorder2'] : $sorder2;

?>
<td><input name="moonsearch" type="radio" value="1"  <?php echo $checked1; ?> /><?php echo SHOW_YES; ?>
<input name="moonsearch" type="radio" value="0" <?php echo $checked2; ?> /><?php echo SHOW_NO; ?> </td>
</tr>
<tr class="firstcolor"><td><?php echo SHOW_NOTICES; ?></td>
<?php
if ($noticesearch == 1) {
	$nchecked1="checked";
	$nchecked2="";
} else {
	$nchecked1="";
	$nchecked2="checked";
}
$nchecked1 = (!isset($_POST['noticesearch']) && isset($_SESSION['s_nchecked1'])) ? $_SESSION['s_nchecked1'] : $nchecked1;
$nchecked2 = (!isset($_POST['noticesearch']) && isset($_SESSION['s_nchecked2'])) ? $_SESSION['s_nchecked2'] : $nchecked2;
?>
<td><input name="noticesearch" type="radio" value="1"  <?php echo $nchecked1; ?> /><?php echo SHOW_YES; ?>
<input name="noticesearch" type="radio" value="0" <?php echo $nchecked2; ?> /><?php echo SHOW_NO; ?></td>
</tr>
<tr class="firstcolor"><td><?php echo SHOW_REPORTS; ?></td>
<?php
if ($reportsearch == 1) {
	$rchecked1="checked";
	$rchecked2="";
} else {
	$rchecked1="";
	$rchecked2="checked";
}
$rchecked1 = (!isset($_POST['reportsearch']) && isset($_SESSION['s_rchecked1'])) ? $_SESSION['s_rchecked1'] : $rchecked1;
$rchecked2 = (!isset($_POST['reportsearch']) && isset($_SESSION['s_rchecked2'])) ? $_SESSION['s_rchecked2'] : $rchecked2;
?>
<td><input name="reportsearch" type="radio" value="1"  <?php echo $rchecked1; ?> /><?php echo SHOW_YES; ?>
<input name="reportsearch" type="radio" value="0" <?php echo $rchecked2; ?> /><?php echo SHOW_NO; ?></td>
</tr>

<tr class="firstcolor"><td><?php echo SHOW_COLONIES; ?></td>
<?php
if ($colonysearch == 1) {
	$cchecked1="checked";
	$cchecked2="";
} else {
	$cchecked1="";
	$cchecked2="checked";
}
$cchecked1 = (!isset($_POST['colonysearch']) && isset($_SESSION['s_cchecked1'])) ? $_SESSION['s_cchecked1'] : $cchecked1;
$cchecked2 = (!isset($_POST['colonysearch']) && isset($_SESSION['s_cchecked2'])) ? $_SESSION['s_cchecked2'] : $cchecked2;
?>
<td><input name="colonysearch" type="radio" value="1"  <?php echo $cchecked1; ?> /><?php echo SHOW_YES; ?>
<input name="colonysearch" type="radio" value="0" <?php echo $cchecked2; ?> /><?php echo SHOW_NO; ?>
&nbsp;&nbsp;&nbsp;<?php echo SHOW_FROM_PLANET; ?> <input class="textfield" name="planet1" type="text" size="3" maxlength="2" value="<?php echo $planet1; ?>">
<?php echo SHOW_TO; ?> <input class="textfield" name="planet2" type="text" size="3" maxlength="2" value="<?php echo $planet2; ?>">
</td>
</tr>

<tr class="firstcolor"><td><?php echo SHOW_SEARCHRANGE; ?></td>
<td><?php echo SHOW_SEARCH_IN; ?> <input class="textfield" name="galaxie" type="text" size="3" maxlength="2" value="<?php echo $galaxie; ?>"> <?php echo SHOW_FROM_SYSTEM; ?> <input class="textfield" name="system1" type="text" size="5" maxlength="3" value="<?php echo $system1; ?>"> <?php echo SHOW_TO; ?> <input class="textfield" name="system2" type="text" size="5" maxlength="3" value="<?php echo $system2; ?>"></td>
</tr>

<tr class="firstcolor"><td><?php echo SHOW_RANK; ?></td>
<td>Top: <input class="textfield" style="text-align:right;" name="minrank" type="text" size="4" maxlength="4" value="<?php echo $minrank; ?>"> - <input class="textfield" style="text-align:right;" name="maxrank" type="text" size="4" maxlength="4" value="<?php echo $maxrank; ?>"></td>
</tr>

<tr class="firstcolor"><td><?php echo SHOW_FRANK; ?></td>
<td>Top: <input class="textfield" style="text-align:right;" name="minfrank" type="text" size="4" maxlength="4" value="<?php echo $minfrank; ?>"> - <input class="textfield" style="text-align:right;" name="maxfrank" type="text" size="4" maxlength="4" value="<?php echo $maxfrank; ?>"></td>
</tr>

<tr class='firstcolor' valign='top'><td colspan='2'><?php echo SHOW_DESCRIPTION; ?></td></tr>
<tr class="firstcolor">
<td><?php echo SHOW_DATE; ?>:</td>
<td>
<input class="textfield" name="datevalue" type="radio" value="0" <?php echo $date_checked0; ?>  /><?php echo SHOW_DATE_0; ?>&nbsp;&nbsp;
<input class="textfield" name="datevalue" type="radio" value="1" <?php echo $date_checked1; ?>  /><?php echo SHOW_DATE_1; ?>&nbsp;&nbsp;
<input class="textfield" name="datevalue" type="radio" value="2" <?php echo $date_checked2; ?>  /><?php echo SHOW_DATE_2; ?>
<br>
<?php
// Tag
pulldowncode("day",1,31,1, $tday);
echo "&nbsp;";
// Monat
pulldowncode("month",1,12,1, $tmonth);
echo "&nbsp;";
// Jahr
pulldowncode("year",2004,date("Y"),1, $tyear);
echo "&nbsp;";
// Stunde
pulldowncode("hour",0,23,1, $thour);
echo "&nbsp;";
// Minute
pulldowncode("minute",0,59,1, $tminute);
echo "&nbsp;";
// Sekunde
pulldowncode("second",0,59,1, $tsecond);
echo "&nbsp;";

?>
</td></tr>
<tr class="firstcolor">
<td><?php echo SHOW_DF_LONG; ?></td>
<td>
<?php echo SHOW_METAL_LONG." ".SHOW_AT_LEAST; ?>: <input class="textfield" name="metal" type="text" size="8" maxlength="10" value="<?php echo $metal; ?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php echo SHOW_CRYSTAL_LONG." ".SHOW_AT_LEAST; ?>: <input class="textfield" name="crystal" type="text" size="8" maxlength="10" value="<?php echo $crystal; ?>"><br>
<?php echo SHOW_BOTH." ".SHOW_AT_LEAST; ?>: <input class="textfield" name="both" type="text" size="8" maxlength="10" value="<?php echo $both; ?>">
</td>
</tr>
<tr class="firstcolor"><td><?php echo SHOW_SORT_BY; ?></td>
<td><input name="sort" type="radio" value="0" <?php echo $schecked1; ?>  /><?php echo SHOW_GALASYSTEM; ?>
<input name="sort" type="radio" value="1" <?php echo $schecked2; ?>  /><?php echo SHOW_PLAYERNAME; ?>
<input name="sort" type="radio" value="2" <?php echo $schecked3; ?>  /><?php echo SHOW_ALLYNAME; ?>
<input name="sort" type="radio" value="3" <?php echo $schecked4; ?>  /><?php echo SHOW_STATUS; ?>
<br>
<input name="sortorder" type="radio" value="0" <?php echo $sorder1; ?>  /><?php echo SHOW_ASC; ?>
<input name="sortorder" type="radio" value="1" <?php echo $sorder2; ?>  /><?php echo SHOW_DESC; ?>
</td></tr>
<tr class="firstcolor"><td><?php echo SHOW_PLAYER_STATUS; ?></td>
<td><input name="status1" type="checkbox" <?php echo $status1; ?>  /><?php echo SHOW_PLAYER_STATUS1; ?>
<input name="status2" type="checkbox" <?php echo $status2; ?>  /><?php echo SHOW_PLAYER_STATUS2; ?>
<input name="status3" type="checkbox" <?php echo $status3; ?>  /><?php echo SHOW_PLAYER_STATUS3; ?>
<input type="hidden" name="done" value="true" />
</td></tr>
<tr class="firstcolor"><td><?php echo SHOW_RESULTS; ?></td>
<td><select name="entries" class="pulldown_code">
<option value="10" <?php if ($_SESSION['s_hits'] == 10) echo "selected"; ?>>10</option>
<option value="20" <?php if ($_SESSION['s_hits'] == 20) echo "selected"; ?>>20</option>
<option value="50" <?php if ($_SESSION['s_hits'] == 50) echo "selected"; ?>>50</option>
<option value="100" <?php if ($_SESSION['s_hits'] == 100) echo "selected"; ?>>100</option>
</select>
</td></tr>

<tr class="firstcolor" valign="top">
<td align="center" colspan="2"><input class="button" type="submit" name="searchbutton" value="<?php echo SHOW_SEARCHBUTTON; ?>" /></td>
</tr></table>
</td></tr>
</table>
</form>



<?php

$whereclause = "WHERE u.userid=$userid";
$wheres = 1;
if (!empty($allysuche) || !empty($spielersuche) || ($moonsearch==1) || ($noticesearch==1) || ($reportsearch == 1) || ($colonysearch==1) || ($status2=="checked") || ($status3=="checked") || isset($_SESSION['s_query']) || !empty($metal) || !empty($crystal) || !empty($both)) {

	if (!empty($allysuche)) {
		$allysuche = str_replace("*","%",$allysuche);
		if ($wheres == 0) $whereclause.=" u.ally LIKE '$allysuche' ";
		else $whereclause.=" AND u.ally LIKE '$allysuche' ";
		$wheres++;
	}
	if (!empty($spielersuche)) {
		$spielersuche = str_replace("*","%",$spielersuche);
		if ($wheres == 0) $whereclause.=" spielername LIKE '$spielersuche' ";
		else $whereclause.=" AND spielername LIKE '$spielersuche' ";
		$wheres++;
	}
	if ($moonsearch == 1) {
		if ($wheres == 0) $whereclause.=" mond='1' ";
		else $whereclause.=" AND mond='1' ";
		$wheres++;
	}
	if ($noticesearch ==1) {
		if ($wheres == 0) $whereclause.=" (notices='true') ";
		else $whereclause.=" AND (notices='true') ";
		$wheres++;
	}
	if ($reportsearch ==1) {
		if ($wheres == 0) $whereclause.=" (reports='true') ";
		else $whereclause.=" AND (reports='true') ";
		$wheres++;
	}
	if ($colonysearch ==1) {
		if ($wheres == 0) $whereclause.=" spielername = '' ";
		else $whereclause.=" AND (spielername='') ";
		$wheres++;
	}
	if (is_numeric($galaxie)) {
		if ($wheres == 0) $whereclause.=" galaxie='$galaxie' ";
		else $whereclause.=" AND galaxie='$galaxie' ";
		$wheres++;
	}
	if (is_numeric($system1)) {
		if ($wheres == 0) $whereclause.=" (system BETWEEN '$system1' AND '$system2') ";
		else $whereclause.=" AND (system BETWEEN '$system1' AND '$system2') ";
		$wheres++;
	}
	if (is_numeric($planet1)) {
		if ($wheres == 0) $whereclause.=" (planet >= '$planet1' AND planet <= '$planet2') ";
		else $whereclause.=" AND (planet >= '$planet1' AND planet <= '$planet2') ";
		$wheres++;
	}
	if ($status1 != "checked") {
		if ($status2 == "checked") {
			if ($wheres == 0) $whereclause.=" (status NOT LIKE '%g%' AND status NOT LIKE '%u%' AND status NOT LIKE '%n%') AND (length(spielername) > 0) ";
			else $whereclause.=" AND (status NOT LIKE '%g%' AND status NOT LIKE '%u%' AND status NOT LIKE '%n%') AND (length(spielername) > 0) ";
			$wheres+=2;
		}
		if ($status3 == "checked") {
			if ($wheres == 0) $whereclause.=" (status LIKE '%i%') AND (length(spielername) > 0) ";
			else $whereclause.=" AND (status LIKE '%i%') AND (length(spielername) > 0) ";
			$wheres+=2;
		}
	} else {
		if ($colonysearch != 1) {
			if ($wheres == 0) $whereclause.=" (length(spielername) > 0) ";
			else $whereclause.=" AND (length(spielername) > 0) ";
			$wheres++;
		}
	}
	if ($date_value == 1) {
		if ($wheres == 0) $whereclause.=" (zeit < $time) ";
		else $whereclause.=" AND (zeit < $time) ";
		$wheres++;
	} elseif ($date_value == 2) {
		if ($wheres == 0) $whereclause.=" (zeit > $time) ";
		else $whereclause.=" AND (zeit > $time) ";
		$wheres++;
	}
	if ($metal > 0) {
		if ($wheres == 0) $whereclause.=" (metall > $metal) ";
		else $whereclause.=" AND (metall > $metal) ";
		$wheres++;
	}
	if ($crystal > 0) {
		if ($wheres == 0) $whereclause.=" (kristall > $crystal) ";
		else $whereclause.=" AND (kristall > $crystal) ";
		$wheres++;
	}
	if ($both > 0) {
		if ($wheres == 0) $whereclause.=" (metall+kristall > $both) ";
		else $whereclause.=" AND (metall+kristall > $both) ";
		$wheres++;
	}
	if ($minrank > 0) {
		if ($wheres == 0) $whereclause.=" (p.rank >= $minrank AND p.rank != 0) ";
		else $whereclause.=" AND (p.rank >= $minrank AND p.rank != 0) ";
		$wheres++;
	}
	if ($minfrank > 0) {
		if ($wheres == 0) $whereclause.=" (p.frank >= $minfrank) ";
		else $whereclause.=" AND (p.frank >= $minfrank) ";
		$wheres++;
	}
	if ($maxrank > 0) {
		if ($wheres == 0) $whereclause.=" (p.rank <= $maxrank AND p.rank != 0) ";
		else $whereclause.=" AND (p.rank <= $maxrank AND p.rank != 0) ";
		$wheres++;
	}
	if ($maxfrank > 0) {
		if ($wheres == 0) $whereclause.=" (p.frank <= $maxfrank AND p.frank != 0) ";
		else $whereclause.=" AND (p.frank <= $maxfrank AND p.frank != 0) ";
		$wheres++;
	}

	$allyquery = "FROM $dbtablename u ".
	"LEFT JOIN $pstablename p ON (u.userid=p.userid and u.spielername=p.playername) ".
	"LEFT JOIN $astablename a ON (u.userid=a.userid and u.ally=a.allyname) ";


	$gesamtquery = "SELECT count(*) as anzahl $allyquery $whereclause";

	$allyquery = "SELECT u.galaxie,u.system,u.planet,u.mond,u.mondgr,u.metall,u.kristall,
				  u.ally,u.planetname,u.spielername,p.status,u.zeit,u.notices,u.reports,
				  p.rank,p.frank,p.rrank,p.points,p.fpoints,p.rpoints,
				  a.rank as arank,a.frank as afrank, a.rrank as arrank,
				  a.points as apoints, a.fpoints as afpoints, a.rpoints as arpoints,  a.allystatus,
				  a.members ".$allyquery." ".$whereclause." ".$sort." ".$limit;

	$res   = mysql_query($gesamtquery) or die(mysql_error());
	$line = mysql_fetch_object($res);
	$anzahl = $line->anzahl;
	$res   = mysql_query($allyquery) or die(mysql_error());

	unset($_SESSION['s_allysuche']);
	unset($_SESSION['s_spielersuche']);
	unset($_SESSION['s_moonsearch']);
	unset($_SESSION['s_noticesearch']);
	unset($_SESSION['s_reportsearch']);
	unset($_SESSION['s_colonysearch']);
	unset($_SESSION['s_checked1']);
	unset($_SESSION['s_checked2']);
	unset($_SESSION['s_nchecked1']);
	unset($_SESSION['s_nchecked2']);
	unset($_SESSION['s_rchecked1']);
	unset($_SESSION['s_rchecked2']);
	unset($_SESSION['s_cchecked1']);
	unset($_SESSION['s_cchecked2']);
	unset($_SESSION['s_sorder1']);
	unset($_SESSION['s_sorder2']);
	unset($_SESSION['s_schecked1']);
	unset($_SESSION['s_schecked2']);
	unset($_SESSION['s_schecked3']);
	unset($_SESSION['s_schecked4']);
	unset($_SESSION['s_galaxie']);
	unset($_SESSION['s_system1']);
	unset($_SESSION['s_system2']);
	unset($_SESSION['s_planet1']);
	unset($_SESSION['s_planet2']);
	unset($_SESSION['s_status1']);
	unset($_SESSION['s_status2']);
	unset($_SESSION['s_status3']);
	unset($_SESSION['s_sort']);
	unset($_SESSION['s_datevalue']);
	unset($_SESSION['s_tyear']);
	unset($_SESSION['s_tmonth']);
	unset($_SESSION['s_tday']);
	unset($_SESSION['s_thour']);
	unset($_SESSION['s_minute']);
	unset($_SESSION['s_second']);
	unset($_SESSION['s_metal']);
	unset($_SESSION['s_crystal']);
	unset($_SESSION['s_both']);
	unset($_SESSION['s_minrank']);
	unset($_SESSION['s_minfrank']);
	unset($_SESSION['s_maxrank']);
	unset($_SESSION['s_maxfrank']);
	unset($_SESSION['s_bbcodes']);

	if ($anzahl > $entries_per_page) {
		$_SESSION['s_allysuche'] = str_replace("%","*",$allysuche);
		$_SESSION['s_spielersuche'] = str_replace("%","*",$spielersuche);
		$_SESSION['s_moonsearch']   = $moonsearch;
		$_SESSION['s_noticesearch'] = $noticesearch;
		$_SESSION['s_reportsearch'] = $reportsearch;
		$_SESSION['s_colonysearch'] = $colonysearch;
		$_SESSION['s_checked1']  = $checked1;
		$_SESSION['s_checked2']  = $checked2;
		$_SESSION['s_nchecked1'] = $nchecked1;
		$_SESSION['s_nchecked2'] = $nchecked2;
		$_SESSION['s_rchecked1'] = $rchecked1;
		$_SESSION['s_rchecked2'] = $rchecked2;
		$_SESSION['s_cchecked1'] = $cchecked1;
		$_SESSION['s_cchecked2'] = $cchecked2;
		$_SESSION['s_sorder1']   = $sorder1;
		$_SESSION['s_sorder2']   = $sorder2;
		$_SESSION['s_schecked1'] = $schecked1;
		$_SESSION['s_schecked2'] = $schecked2;
		$_SESSION['s_schecked3'] = $schecked3;
		$_SESSION['s_schecked4'] = $schecked4;
		$_SESSION['s_galaxie'] = $galaxie;
		$_SESSION['s_system1'] = $system1;
		$_SESSION['s_system2'] = $system2;
		$_SESSION['s_planet1'] = $planet1;
		$_SESSION['s_planet2'] = $planet2;
		$_SESSION['s_status1'] = $status1;
		$_SESSION['s_status2'] = $status2;
		$_SESSION['s_status3'] = $status3;
		$_SESSION['s_sort']    = $sort;
		$_SESSION['s_datevalue'] = $date_value;
		$_SESSION['s_tyear']   = $tyear;
		$_SESSION['s_tmonth']  = $tmonth;
		$_SESSION['s_tday']    = $tday;
		$_SESSION['s_thour']   = $thour;
		$_SESSION['s_minute']  = $tminute;
		$_SESSION['s_second']  = $tsecond;
		$_SESSION['s_metal']   = $metal;
		$_SESSION['s_crystal'] = $crystal;
		$_SESSION['s_both']    = $both;
		$_SESSION['s_minrank']    = $minrank;
		$_SESSION['s_minfrank']   = $minfrank;
		$_SESSION['s_maxrank']    = $maxrank;
		$_SESSION['s_maxfrank']   = $maxfrank;
	}

	if ($anzahl > 0) {


		if (isset($_POST['searchbutton']) || true) {
			starttable($anzahl,$page,true);
			while ($line = mysql_fetch_object($res)) {
				displayresult(false,$line->galaxie,$line->system,$line->planet,$line->mond,$line->mondgr,$line->metall,
				$line->kristall,$line->ally,$line->planetname,$line->spielername,$line->status,
				$line->zeit,$line->rank,$line->frank,$line->rrank,$line->points,$line->fpoints,$line->rpoints,
				$line->arank,$line->afrank,$line->arrank,$line->apoints,$line->afpoints,$line->arpoints,
				$line->members,$line->notices,$line->reports,$line->allystatus);
			}
			echo "<tr class=\"firstcolor\"><td colspan=\"10\" align=\"center\">";
			if ($anzahl > $entries_per_page) draw_pagenumbers($page,$anzahl,$entries_per_page,$_SERVER['PHP_SELF'],"page");
			echo "</td></tr>";
			closetable();
		} 
	} else {
		echo "<div align=\"center\">".SHOW_NOTHING."</div>\n";
	}

}


function displayresult($show_as_bb_code,$galaxie,$system,$planetnummer,$mond,$mondgr,$metall,$kristall,$ally,$planetname,$spielername,$spielerstatus,$zeit,
$rank,$frank,$rrank,$points,$fpoints,$rpoints,$arank,$afrank,$arrank,$apoints,$afpoints,$arpoints,
$members,$notice,$report,$allystats) {

	$zeit = date("d.m.Y  H:i",$zeit);
	global $ostat_universe,$ostat_server;

	if (!empty($ostat_universe) && is_numeric($ostat_universe) && !empty($ostat_server) && (
	$ostat_server == "de" || $ostat_server == "org")) {
		$ostat = true;
	} else $ostat = false;

	if ($mond == 1) {
		$mond = "M";
		if ($mondgr > 0) $mondgr = number_format($mondgr,0,",",".")." km";
		else $mondgr = SHOW_UKMOONSIZE;
	}
	else {
		$mond = "&nbsp;";
		$mondgr = "&nbsp;";
	}
	if ($metall > 0 || $kristall > 0) {
		$tf = 'M:'.number_format($metall,0,",",".").' <br>K:'.number_format($kristall,0,",",".");
	} else {
		$tf = '';
	}

	if (!empty($members)) $a_alt = SHOW_RANK.": $arank / ".SHOW_MEMBERS.": $members";
	else $a_alt = "";
	if ($rank > 0) $p_alt = SHOW_RANK.": $rank / $frank";
	else $p_alt = SHOW_NOTRANKED;

	if (!$show_as_bb_code){
		echo'
	   <tr class="firstcolor">
	    <td width="100" align="center"><a class="resultlink" href="view.php?gala='.$galaxie.'&amp;system='.$system.'&amp;from=show"><span style="white-space: nowrap;">'.$galaxie.':'.$system.':'.$planetnummer.'</span></a></td>
	    ';
		if ($mondgr != "&nbsp;") {
			echo '<td align="center" onmouseover=\'this.T_WIDTH=150;return escape("'.$mondgr.'")\'>'.$mond.'</td>';
		} else {
			echo '<td align="center">&nbsp;</td>';
		}
		echo '
	    <td align="center" style="font-size:6pt;">'.$tf.'</td>
	    <td align="center"><table width="100%"><tr class="firstcolor"><td align="center"><a class="resultlink" href="'.$_SERVER['PHP_SELF'].'?ally='.$ally.'&new=true"';
		if (!empty($members) && !empty($arank)) {
			if (!empty($arank)) {
				echo ' onmouseover=\'this.T_WIDTH=250;return escape("'.htmlentities('<div style=font-size:10pt;>'.STATS_ALLYSTATS.":</div><br>".STATS_MEMBERS.": ".$members."<br>".SHOW_RANK.": #".$arank." - ".STATS_SCORE.": ".number_format($apoints,0,",",".")."<br>".STATS_FLEET.": #".$afrank." - ".STATS_SCORE.": ".number_format($afpoints,0,",",".")."<br>".STATS_RESEARCH.": #".$arrank." - ".STATS_SCORE.": ".number_format($arpoints,0,",",".")).'")\' >';
			} else {
				echo ' onmouseover=\'this.T_WIDTH=250;return escape("'.htmlentities(SHOW_NOTRANKED).'")\' >';
			}
		} else {
			echo " >";
		}
		echo '<span class="'.$allystats.'" style="white-space: nowrap;">'.$ally.'</span></a></td>';
		if ($ostat && !empty($ally)) echo "<td align=\"right\"><a target=\"ostat\" href=\"http://uni$ostat_universe.ostat.$ostat_server/index.php?ext=allyueber&amp;name=".$ally."\"><img src=\"../images/os.gif\" border=\"0\"></a></td>";
		else echo "<td>&nbsp;</td>";
		echo "</tr></table>";
		echo '</td>
	    <td align="center"><span style="white-space: nowrap;">'.$planetname.'</span></td>
	    <td align="center"><table width="100%"><tr class="firstcolor"><td align="center"><a ';
		if (!empty($rank)) {
			echo ' onmouseover=\'this.T_WIDTH=250;return escape("'.htmlentities('<div style=font-size:10pt;>'.STATS_PLAYERSTATS.":</div><br>".SHOW_RANK.": #".$rank." - ".STATS_SCORE.": ".number_format($points,0,",",".")."<br>".STATS_FLEET.": #".$frank." - ".STATS_SCORE.": ".number_format($fpoints,0,",",".")."<br>".STATS_RESEARCH.": #".$rrank." - ".STATS_SCORE.": ".number_format($rpoints,0,",",".")).'")\' ';
		} else {
			echo ' onmouseover=\'this.T_WIDTH=250;return escape("'.htmlentities(SHOW_NOTRANKED).'")\' ';
		}
	}

	if (!$show_as_bb_code) {
		echo ' class="resultlink" href="'.$_SERVER['PHP_SELF'].'?spieler='.$spielername.'&new=true"><span style="white-space: nowrap;">';
		// Status
		$openspans = 0;
		if (strpos($spielerstatus,"g") !== false) {
			echo "<span class=\"banned\">";
			$openspans++;
		}
		if (strpos($spielerstatus,"u") !== false) {
			echo "<span class=\"vacation\">";
			$openspans++;
		} elseif (strpos($spielerstatus,"n") !== false) {
			echo "<span class=\"noob\">";
			$openspans++;
		} elseif (strpos($spielerstatus,"i") !== false) {
			echo "<span class=\"longinactive\">";
			$openspans++;
		} elseif (strpos($spielerstatus,"I") !== false) {
			echo "<span class=\"inactive\">";
			$openspans++;
		}
	}

	if (!$show_as_bb_code) {
		echo $spielername;
		for ($i=$openspans;$i>0;$i--) {
			echo "</span>";
		}
		// endstatus
		echo '</span></a></td>';
		if ($ostat && !empty($spielername)) echo "<td align=\"right\"><a target=\"ostat\" href=\"http://uni$ostat_universe.ostat.$ostat_server/index.php?ext=player&amp;name=".$spielername."\"><img src=\"../images/os.gif\" border=\"0\"></a></td>";
		else echo "<td>&nbsp;</td>";
		echo "</tr></table>";
		echo '</td>
	<td width="20" align="center">';
	}
	switch ($_SESSION['lang']) {
		case "english" :
			print_status($show_as_bb_code,$spielerstatus,"b","v"); // banned, vacation, noob, inactive, long inactive
			break;
		default: 
			print_status($show_as_bb_code,$spielerstatus);
			break;
	}
	if (!$show_as_bb_code) {
		echo '</td>
		<td width="250" align="center">'.$zeit.'</td>
		';
		if ($notice == "true") echo '<td align="center"><a href="notices.php?action=view&amp;coordinates='."$galaxie:$system:$planetnummer".'"><img src="../images/notice.gif" border="0"></a></td>';
		else echo '<td align="center"><a href="notices.php?action=edit&amp;coordinates='."$galaxie:$system:$planetnummer".'"><img src="../images/no_notice.gif" border="0"></a></td>';
		if ($report == "true") echo '<td align="center"><a href="reports.php?coordinates='."$galaxie:$system:$planetnummer".'&amp;moon=unknown"><img src="../images/spio.gif" border="0"></a></td>';
		else echo '<td align="center"><img src="../images/no_spio.gif" border="0"></td>';
		echo "</tr>\n";
	}
}



function starttable($number,$page,$show_tablehead = true) {
	global $entries_per_page;
	$to = ($page*$entries_per_page < $number) ? $page*$entries_per_page : $number;
	echo '<table width="95%" border="0" cellspacing="2" cellpadding="0" align="center">';
	echo "<tr class=\"firstcolor\"><td colspan=\"10\" align=\"center\">";
	if ($number > $entries_per_page) draw_pagenumbers($page,$number,$entries_per_page,$_SERVER['PHP_SELF'],"page");
	echo "</td></tr>";
	if ($show_tablehead) {
		echo "<tr class=\"firstcolor\"><td align=\"center\" colspan=\"10\">";
		// Colors
	?>
	<span class="bg_nothing">&nbsp;&nbsp;&nbsp;&nbsp;</span> <?php echo STATS_NOTHING; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<span class="bg_neutral">&nbsp;&nbsp;&nbsp;&nbsp;</span> <?php echo STATS_NEUTRAL; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<span class="bg_boycott">&nbsp;&nbsp;&nbsp;&nbsp;</span> <?php echo STATS_BOYCOTT; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<span class="bg_nap">&nbsp;&nbsp;&nbsp;&nbsp;</span> <?php echo STATS_NAP; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<span class="bg_ally">&nbsp;&nbsp;&nbsp;&nbsp;</span> <?php echo STATS_ALLIED; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<span class="bg_war">&nbsp;&nbsp;&nbsp;&nbsp;</span> <?php echo STATS_WAR; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<span class="bg_own">&nbsp;&nbsp;&nbsp;&nbsp;</span> <?php echo STATS_OWN; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<span class="bg_wing">&nbsp;&nbsp;&nbsp;&nbsp;</span> <?php echo STATS_WING; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<?php
	echo "</td></tr>\n";
	echo "<tr><td align=\"center\" class=\"tblhead\" colspan=\"10\">".SHOW_HITS.": ".(($page-1)*$entries_per_page+1)."-".$to." ".SHOW_OF." $number</td></tr>\n";
	echo'
	<tr>
	<td width="90" align="center" class="tblhead">'.SHOW_ADDRESS.'</td>
	<td width="90" align="center" class="tblhead">'.SHOW_MOON.'</td>
	<td width="90" align="center" class="tblhead">'.SHOW_DF.'</td>
	<td align="center"class="tblhead">'.SHOW_ALLYSORT.'</td>
	<td align="center"class="tblhead">'.SHOW_PLANET.'</td>
	<td align="center"class="tblhead">'.SHOW_PLAYERNAME.'</td>
	<td width="20" align="center"class="tblhead">'.SHOW_STATUS.'</td>
	<td width="250" align="center"class="tblhead">'.SHOW_CURRENTNESS.'</td>
	<td width="250" align="center"class="tblhead">'.SHOW_NOTICERES.'</td>
	<td width="250" align="center"class="tblhead">'.SHOW_REPORTS_SHORT.'</td>
	</tr>';
	}
}

function closetable() {
	echo "</table>";
}

function pulldowncode($name,$startval,$endval,$interval,$selected=0) {
	echo "<select name=\"$name\" class=\"pulldown_code\">\n";
	for ($i=$startval;$i<=$endval;$i += $interval) {
		echo "<option value=\"$i\"";
		if ($selected == $i) echo "selected";
		echo ">$i</option>\n";
	}
	echo "</select>\n";
}



makefooter();
?>